package com.nexus.all.controller;

import com.nexus.all.dto.UserTimeMailDTO;
import com.nexus.all.service.UserTimeMailService;
import com.nexus.bean.annotation.valid.AddGroup;
import com.nexus.bean.result.Result;
import com.nexus.web.controller.CommonController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequestMapping("/userTimeMail")
@RestController
@AllArgsConstructor
@Api(tags = "时间邮件")
public class UserTimeMailController extends CommonController {
    private UserTimeMailService userTimeMailService;

    @ApiOperation(value = "保存时间邮件")
    @PostMapping("save")
    public Result saveTameMail(@RequestBody @Validated(AddGroup.class) UserTimeMailDTO dto) {
        dto.setUserId(getUser().getId());
        userTimeMailService.saveTimeMail(dto);
        return Result.newSuccess();
    }
}
